home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Reversed wipes ƒ / Mr. Do reversed.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-11  |  4.1 KB  |  186 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Mr. Do reversed.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define        BoxSize    4
  32. #define CorrectTime 1
  33. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  34. #define theWindowWidth (boundsRect.right-boundsRect.left)
  35.  
  36. pascal short MrDoReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  37.  
  38. /* 25 regions, in a 5 x 5 grid.  Go around to each region in a spiral pattern,
  39.    starting with the center square, and alternatively scroll it up or down. */
  40.    
  41. pascal short MrDoReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  42. {
  43.     int            x, y;
  44.     int            vgap,hgap;
  45.     Rect        theRect, dest;
  46.     Rect        bounds[25];
  47.     Boolean        everyOther;
  48.     
  49.     vgap=theWindowHeight/5;
  50.     hgap=theWindowWidth/5;
  51.     
  52.     for (x=0; x<25; x++)
  53.     {
  54.         switch (x)
  55.         {
  56.             case 0:
  57.             case 1:
  58.             case 2:
  59.             case 3:
  60.             case 4:
  61.                 bounds[x].top=0;
  62.                 break;
  63.             case 15:
  64.             case 16:
  65.             case 17:
  66.             case 18:
  67.             case 5:
  68.                 bounds[x].top=vgap;
  69.                 break;
  70.             case 14:
  71.             case 23:
  72.             case 24:
  73.             case 19:
  74.             case 6:
  75.                 bounds[x].top=vgap*2;
  76.                 break;
  77.             case 13:
  78.             case 22:
  79.             case 21:
  80.             case 20:
  81.             case 7:
  82.                 bounds[x].top=vgap*3;
  83.                 break;
  84.             case 12:
  85.             case 11:
  86.             case 10:
  87.             case 9:
  88.             case 8:
  89.                 bounds[x].top=vgap*4;
  90.                 break;
  91.         }
  92.         switch (x)
  93.         {
  94.             case 0:
  95.             case 15:
  96.             case 14:
  97.             case 13:
  98.             case 12:
  99.                 bounds[x].left=0;
  100.                 break;
  101.             case 1:
  102.             case 16:
  103.             case 23:
  104.             case 22:
  105.             case 11:
  106.                 bounds[x].left=hgap;
  107.                 break;
  108.             case 2:
  109.             case 17:
  110.             case 24:
  111.             case 21:
  112.             case 10:
  113.                 bounds[x].left=hgap*2;
  114.                 break;
  115.             case 3:
  116.             case 18:
  117.             case 19:
  118.             case 20:
  119.             case 9:
  120.                 bounds[x].left=hgap*3;
  121.                 break;
  122.             case 4:
  123.             case 5:
  124.             case 6:
  125.             case 7:
  126.             case 8:
  127.                 bounds[x].left=hgap*4;
  128.                 break;
  129.         }
  130.         bounds[x].bottom=bounds[x].top+vgap;
  131.         bounds[x].right=bounds[x].left+hgap;
  132.         OffsetRect(&(bounds[x]), boundsRect.left, boundsRect.top);
  133.     }
  134.     
  135.     for (y=24; y>=0; y--)
  136.     {        
  137.         if (!(y%2))   /* these scroll up */
  138.         {
  139.             dest=bounds[y];
  140.             dest.top=dest.bottom-BoxSize;
  141.             
  142.             theRect=bounds[y];
  143.             theRect.bottom=theRect.top+BoxSize;
  144.             
  145.             for (x=bounds[y].bottom-bounds[y].top-BoxSize; x>0; x-=BoxSize)
  146.             {
  147.                 StartTiming();
  148.                 ScrollRect(&bounds[y], 0, -BoxSize, 0L);
  149.                 CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  150.                         &theRect, &dest, 0, 0L);
  151.                 theRect.bottom+=BoxSize;
  152.                 theRect.top+=BoxSize;
  153.                 if (everyOther)
  154.                     TimeCorrection(CorrectTime);
  155.                 everyOther=!everyOther;
  156.             }
  157.         }
  158.         else    /* these scroll down */
  159.         {
  160.             dest=bounds[y];
  161.             dest.bottom=dest.top+BoxSize;
  162.             
  163.             theRect=bounds[y];
  164.             theRect.top=theRect.bottom-BoxSize;
  165.             
  166.             for(x = bounds[y].bottom-bounds[y].top-BoxSize; x > 0; x -= BoxSize)
  167.             {
  168.                 StartTiming();
  169.                 ScrollRect(&bounds[y], 0, BoxSize, 0L);
  170.                 CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  171.                         &theRect, &dest, 0, 0L);
  172.                 theRect.bottom-=BoxSize;
  173.                 theRect.top-=BoxSize;
  174.                 if (everyOther)
  175.                     TimeCorrection(CorrectTime);
  176.                 everyOther=!everyOther;
  177.             }
  178.         }
  179.         
  180.         CopyBits(&(sourceGrafPtr->portBits),&(destGrafPtr->portBits),
  181.                     &bounds[y],&bounds[y],0,0L);
  182.     }
  183.     
  184.     return 0;
  185. }
  186.